/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Trabalho3.RegrasPasswordChecker01;

import Trabalho3.RuleFactory;

/**
 *
 * @author geraldo
 */
public class RegraDigitos implements RuleFactory{
    
    final int BONUS_DIGITOS_UNICO = 5;
    final int BONUS_DIGITOS_ACIMA_DE_DOIS = 10;
    String password;

    public RegraDigitos(String password) {
        this.password = password;
    }
    
    
    @Override
    public int calcularRegra() {int counter = 0;
        char[] arraySenha = password.toCharArray();
        for (char c : arraySenha) {
            if (Character.isDigit(c)) {
                counter++;
            }
        }
        if (counter <= 0) {
            return 0;
        }
        return (counter > 2) ? BONUS_DIGITOS_ACIMA_DE_DOIS : BONUS_DIGITOS_UNICO;}
    
}
